Use Singleton Pattern (USP)

Description:

USP detects non-sealed classes which have only class members. Such classes cannot be customized, i.e., it is not possible to derive a subclass from it and redefine one or more methods; therefore, the Singleton pattern should be used instead. According to this pattern, all class variables and methods should be replaced with instance members and there should be a class method GetInstance() that returns the single instance of the class.

Singletons should declare strict private no-argument constructors to show that they are not intended to be instantiated.

Incorrect:

Registry = class
    strict private
      class map:Hashtable;
 
    public
      class function GetProperty(name:String):String;
end;

Correct:

Registry = class
    strict private
      class instance:Registry;
      map:Hashtable;
 
    public
      class function GetInstance():Registry;
      function GetProperty(name:String):String;
end;